

package com.coding4play.mqtt.broker.config;


import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * 服务配置
 */
@ConfigurationProperties(prefix = "spring-mqtt.broker")
@Getter
@Setter
@Configuration
public class BrokerProperties {
    //Broker唯一标识
    private String id = "spring-mqtt";

    //SSL启动的IP
    private String host = "127.0.0.1";
    // SSL端口号, 默认8885端口
    private Integer port = 8885;

    private Boolean clusterEnabled = false;

    //SSL密钥文件密码
    private String sslPassword = "";
    private Boolean sslEnabled = true;

    //是否开启Epoll模式
    private Boolean useEpoll = false;

    // MQTT.Connect消息必须通过用户名密码验证
    private Boolean mqttPasswordMust = true;

    //socket参数, 存放已完成三次握手请求的队列最大长度, 默认511长度
    private Integer soBacklog = 511;

    //Socket参数, 是否开启心跳保活机制, 默认开启
    private Boolean soKeepAlive = true;

    //心跳时间(秒), 默认60秒, 该值可被客户端连接时相应配置覆盖
    private Integer keepAlive = 60;

    /**
     * netty 线程数
     */
    private Integer bossGroupThreads = 2;
    private Integer workerGroupThreads = 8;


    private WebsocketProperties websocket = new WebsocketProperties();
    private KafkaProperties kafka = new KafkaProperties();


    @NoArgsConstructor
    @Getter
    @Setter
    public class WebsocketProperties {
        private Boolean enable = false;
        private Integer port = 9995;
        private String path = "/mqtt/ws";
    }

    @NoArgsConstructor
    @Getter
    @Setter
    public class KafkaProperties {
        private Boolean brokerEnabled = false;
        //kafka转发主题
        private String producerTopic = "mqtt_publish";
    }

}


